package com.aims.logic.example.component;

import com.aims.logic.sdk.annotation.LogicItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
public class SqlExecutor {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @LogicItem(name = "查询SQL", group = "数据库", memo = "执行查询语句，返回查询结果集")
    public List<Map<String, Object>> query(String sql) {
        return jdbcTemplate.queryForList(sql);
    }
    @LogicItem(name = "执行SQL", group = "数据库", memo = "执行更新语句，返回受影响的行数")
    public int execute(String sql) {
        return jdbcTemplate.update(sql);
    }
}
